﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DLMemberPointMS.Entity.POCOModel;
using DLMemberPointMS.Common;
using DLMemberPointMS.Entity.ViewModel;
namespace DLMemberPointMS.Business
{
    public   class CountJianjiFenService : BaseService<ConsumeOrders>
    {
        /// <summary>
        /// 减积分
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        public OperateResult GetJianJifen(JianJiFenMemberViewModel viewModel)
        {
            var query = PredicateExtensions.True<ConsumeOrders>();

            if (!string.IsNullOrEmpty(viewModel.MC_CardID))
            {
                query = query.And(e => e.MC_CardID.Contains(viewModel.MC_CardID));
            }

            query = query.And(e => (orderTypeEnum)e.CO_OrderType == orderTypeEnum.减积分);
            int rowCount = 0;//总条数
            MemCardsService mc = new MemCardsService();
            var pageData = GetList(viewModel.page, viewModel.limit, ref rowCount, query, e => e.CO_ID, true).Select(
                e => new
                {
                    //name = mc.GetMC_Name(e.MC_CardID),
                    e.CO_OrderCode,
                    e.CO_GavePoint,
                    e.CO_CreateTime,
                    e.CO_Remark,
                    e.MC_CardID,
                    e.MemCards.MC_Name
                }).ToList();
            //pageData.name=mc.Find(pageData.MC_CardID)
            return new OperateResult(code.Success, "", pageData, rowCount);
        }
    }
}
